﻿@namespace IoTSharp.ClientApp
@inherits LayoutComponentBase

<AntDesign.Pro.Layout.BasicLayout 
    Logo="@("https://portrait.gitee.com/uploads/avatars/namespace/790/2372506_IoTSharp_1581268628.png!avatar100")"
    MenuData="MenuData">
    <RightContentRender>
        <IoTSharp.ClientApp.Components.RightContent />
    </RightContentRender>
    <ChildContent>
        @Body
    </ChildContent>
</AntDesign.Pro.Layout.BasicLayout>
<SettingDrawer />
@using IoTSharp.Sdk.Http;
@inject HttpClient HttpClient
@inject IoTSharpClient client
@inject NavigationManager NavigationManager
@code
{
    private MenuDataItem[] MenuData { get; set; } = {};

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        MenuData = await HttpClient.GetFromJsonAsync<MenuDataItem[]>("data/menu.json");
            if (!client.IsLogin)
            {
                NavigationManager.NavigateTo("/user/login");
            }
    }
}